package at.fhooe.mc.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Polygon;

import javax.swing.JPanel;

public class JTrianglePanelDown extends JPanel  {

	private Color trianglecolor = Color.lightGray;
	private boolean filled = false;
	private String targetFloorDown = "";

	public void setTrianglecolorOn(boolean on, String targetFloor) {

		filled = on;

        targetFloorDown = targetFloor;
		this.repaint();
	}

   public Color getTrianglecolor() {
        return trianglecolor;
    }


	protected void paintComponent(Graphics g) {

		super.paintComponent(g);

		Point p1 = new Point(0,0);
		Point p2 = new Point(50,50);
		Point p3 = new Point(100,0);

		int[] xs = { p1.x, p2.x, p3.x };
		int[] ys = { p1.y, p2.y, p3.y };
		Polygon triangle = new Polygon(xs, ys, xs.length);
		g.setFont(new Font("Helvetica", Font.PLAIN, 16));
		g.setColor(trianglecolor);

		if(filled){
			trianglecolor = Color.lightGray;
	    	g.setColor(trianglecolor);
	        g.fillPolygon(triangle);
	        g.setColor(Color.black);
	        g.drawString(targetFloorDown.toString(), 45, 35);
	    } else {
	    	trianglecolor = Color.gray;
	    	g.setColor(trianglecolor);
	    	g.drawPolygon(triangle);
	    }

		}

}
